home *** CD-ROM | disk | FTP | other *** search
- class BuildingPart extends smashing.Renderable
- {
- var hasObstacle;
- var bhandler;
- var oData;
- var nSegment;
- var gfx;
- var aLines;
- var x;
- var y;
- var mcGerm = null;
- function BuildingPart()
- {
- super();
- }
- function init(oHandler, bObst, nType, oBData, segment)
- {
- this.hasObstacle = bObst;
- this.bhandler = oHandler;
- this.oData = oBData;
- this.nSegment = segment;
- if(bObst == true)
- {
- this.gotoAndStop("obst");
- }
- else
- {
- this.gotoAndStop("open");
- }
- this.gfx.gotoAndStop(nType);
- this.aLines = [];
- if(bObst == true)
- {
- if(this.gfx.p3 == undefined)
- {
- if(this.gfx.p2 == undefined)
- {
- this.aLines.push(new smashing.Line(this.gfx.p0._x + this.x,this.gfx.p0._y + this.y,this.gfx.p1._x + this.x,this.gfx.p1._y + this.y));
- }
- else
- {
- this.aLines.push(new smashing.Line(this.gfx.p1._x + this.x,this.gfx.p1._y + this.y,this.gfx.p2._x + this.x,this.gfx.p1._y + this.y));
- }
- }
- else
- {
- this.aLines.push(new smashing.Line(this.gfx.p1._x + this.x,this.gfx.p1._y + this.y,this.gfx.p2._x + this.x,this.gfx.p2._y + this.y));
- }
- }
- }
- function render()
- {
- var _loc2_ = smashing.Viewport.getPos(this);
- if(_loc2_.x < BuildingHandler.leftEdge || _loc2_.x > smashing.Viewport.halfWidth)
- {
- var _loc3_ = false;
- this.bhandler.removeBuilding(this,_loc3_);
- }
- else if(_loc2_.y > smashing.Viewport.halfHeight || _loc2_.y < BuildingHandler.topEdge - this._height)
- {
- this._visible = false;
- }
- else
- {
- this._visible = true;
- this._x = _loc2_.x + smashing.Viewport.centerX;
- this._y = _loc2_.y + smashing.Viewport.centerY;
- }
- }
- }
-